package com.example.logintest.controller;

import com.example.logintest.bean.User;
import com.example.logintest.dao.GetAll;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/test")
public class GetAllController {

    @Autowired
    GetAll getAll;
    @RequestMapping("/getall")
    public Object getAll(){
        List<User> data  = getAll.getAll();
        Map<String,Object> map =new HashMap<>();

        if(data!=null&&data.size()>0){
            map.put("code",200);
            map.put("msg", "success!");
            map.put("data",data);
        }else{
            map.put("code",100);
            map.put("msg", "fail!");
        }



        return map;
    }

}
